home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 011-020 / amok19 / trackdisksupport / trackdisksupport.def < prev    next >
Text File  |  1993-11-04  |  8KB  |  208 lines

  1. (**********************************************************************
  2.  
  3.     :Program.    TrackDiskSupport.def
  4.     :Contents.   Support to access trackdisk/hddisk sectors
  5.     :Author.     Fridtjof Siebert [fbs]
  6.     :Address.    [fbs] Nobileweg 67, D7000 Stuttgart 40
  7.     :Phone.      [fbs] (0)711/822509
  8.     :Author.     Nicolas Benezan [bne]
  9.     :Address.    [bne] Postwiesenstr. 2, D7000 Stuttgart 60
  10.     :Phone.      [bne] 0711/333679
  11.     :Copyright.  Public Domain, no commercial use !!!
  12.     :Language.   Modula-2
  13.     :Translator. M2Amiga A+L V3.2d
  14.     :Imports.    DosSupport1.3, TaskMemory [bne]
  15.     :History.    V1.0 [fbs] 5.Dez.1988
  16.     :History.    V1.1 [bne] 12.May.1989 (adapted m2c V3.2d)
  17.     :History.    V2.0 [bne] 13.May.1989 (+ other drivetypes, DHx: etc.)
  18.     :History.    V2.1 [bne] 14.May.1989 (+ InhibitDrive, bugs fixed)
  19.  
  20. **********************************************************************)
  21. DEFINITION MODULE TrackDiskSupport;
  22.  
  23. FROM Dos         IMPORT ProcessId;
  24. FROM DosSupport  IMPORT DiskInfoPtr;
  25. FROM Exec        IMPORT Byte;
  26. FROM SYSTEM      IMPORT ADDRESS, LONGSET;
  27.  
  28. TYPE
  29.   DiskUnit;
  30.   Name=ARRAY [0..31] OF CHAR;
  31.   DeviceInfo=RECORD
  32.     devName:Name;        (* example: "trackdisk.device" *)
  33.     devUnit:LONGINT;     (* unit number *)
  34.     devFlags:LONGSET;    (* flags for OpenDevice() *)
  35.     blockLen:LONGINT;    (* bytes per block *)
  36.     trackLen:LONGINT;    (* bytes per track *)
  37.     cylinderLen:LONGINT; (* bytes per cylinder *)
  38.     numBlocks:LONGINT;   (* total number of blocks per disk or partition *)
  39.     offset:LONGINT;      (* offset for partition origin *)
  40.     disk:DiskInfoPtr;    (* MountList entries, e.g. LowCyl HighCyl... *)
  41.     handler:ProcessId;   (* Dos file handler process *)
  42.   END;
  43.  
  44. VAR
  45.   TrackDiskAllocProc:PROCEDURE(VAR ADDRESS,LONGINT);
  46.   TrackDiskDeallocProc:PROCEDURE(VAR ADDRESS);
  47.  
  48. PROCEDURE OpenDiskDevice(    DeviceName: ARRAY OF CHAR;
  49.                          VAR Unit: DiskUnit): Byte;
  50.  
  51. (*:Input.    DeviceName: Name of the devive (examples: "DF1", "DH0", "JH0")
  52.   :Output.   Unit: internal data structure to handle this device unit
  53.   :Result.   Error number or 0 if successfully
  54.   :Semantic. Determines which device and unit is responsible for the
  55.   :Semantic. specified drive and opens it.
  56. *)
  57.  
  58. PROCEDURE CloseDiskDevice(Unit: DiskUnit);
  59.  
  60. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  61.   :Semantic. Closes a disk device unit.
  62. *)
  63.  
  64. PROCEDURE GetDeviceInfo(    Unit: DiskUnit;
  65.                         VAR Info: DeviceInfo);
  66.  
  67. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  68.   :Output.   Info: Information about that device (LowCyl, HighCyl and so on)
  69. *)
  70.  
  71. PROCEDURE GetDiskChange(Unit: DiskUnit): LONGINT;
  72.  
  73. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  74.   :Result.   Disk Change number (necessary to detect disk changes)
  75. *)
  76.  
  77. PROCEDURE ChangeState(Unit: DiskUnit): BOOLEAN;
  78.  
  79. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  80.   :Result.   TRUE if disk inserted, else FALSE
  81. *)
  82.  
  83. PROCEDURE ProtStatus(Unit: DiskUnit): BOOLEAN;
  84.  
  85. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  86.   :Result.   TRUE if write enabled
  87. *)
  88.  
  89. PROCEDURE Motor(Unit: DiskUnit; On: BOOLEAN): BOOLEAN;
  90.  
  91. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  92.   :Input.    On: turm Motor on (TRUE) or off (FALSE)
  93.   :Result.   old motor state: TRUE = on, FALSE = off
  94.   :Semantic. Turns motor on or off according to <On>.
  95. *)
  96.  
  97. PROCEDURE Seek(Unit: DiskUnit; BlockNum: LONGINT): Byte;
  98.  
  99. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  100.   :Input.    BlockNum: where to seek to. Must be a multiple of
  101.   :Input.              surfaces * numSecs
  102.   :Output.   Error number or 0 if successful
  103.   :Semantic. Moves head to specified track
  104.   :Note.     WARNING: surfaces and numSecs depend on the drive type
  105.   :Note.     (harddisks...) and mut be determined by GetDeviceInfo()!!!
  106. *)
  107.  
  108. PROCEDURE BlockNumber(Unit: DiskUnit;
  109.                       Cylinder, Sector, Head: LONGINT): LONGINT;
  110.  
  111. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  112.   :Input.    Cylinder, Sector, Head: location of the block on disk
  113.   :Result.   logical number of that block (for ReadBlock or WriteBlock)
  114. *)
  115.  
  116. PROCEDURE ReadBlock(Unit: DiskUnit;
  117.                     Block: LONGINT;
  118.                     NumBlocks: CARDINAL;
  119.                     Buffer: ADDRESS;
  120.                     ChangeCnt: LONGINT): Byte;
  121.  
  122. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  123.   :Input.    Block:    number of the first block to be read
  124.   :Input.    NumBlocks:how many blocks to be read
  125.   :Input.    Buffer:   at least 512 Bytes of Chip memory to store data
  126.   :Input.    ChangeCnt:last changenumber to check diskchanges
  127.   :Result.   error number or 0 if successful
  128.   :Semantic. Reads BlockCnt Blocks from Disk
  129. *)
  130.  
  131. PROCEDURE WriteBlock(Unit: DiskUnit;
  132.                      Block: LONGINT;
  133.                      NumBlocks: CARDINAL;
  134.                      Buffer: ADDRESS;
  135.                      ChangeCnt: LONGINT): Byte;
  136.  
  137. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  138.   :Input.    Block:    number of the first block to be read
  139.   :Input.    NumBlocks:how many blocks to be read
  140.   :Input.    Buffer:   at least 512 Bytes of Chip memory to store data
  141.   :Input.    ChangeCnt:last changenumber to check diskchanges
  142.   :Result.   error number or 0 if successful
  143.   :Semantic. Writes BlockCnt Blocks to Disk
  144. *)
  145.  
  146. PROCEDURE Update(Unit: DiskUnit;
  147.                  ChangeCnt: LONGINT): Byte;
  148.  
  149. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  150.   :Input.    ChangeCnt: last changenumber to check diskchanges
  151.   :Result.   error number or 0 if successful
  152.   :Semantic. Forces buffers to be written to disk (flush buffers)
  153. *)
  154.  
  155. PROCEDURE FormatTrack(Unit: DiskUnit;
  156.                       Cylinder: CARDINAL;
  157.                       Head: CARDINAL;
  158.                       Buffer: ADDRESS;
  159.                       ChangeCnt: LONGINT): Byte;
  160.  
  161. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  162.   :Input.    Cylinder, Head: location of the track to be formatted
  163.   :Input.    Buffer: Buffer containing numSecs*sector bytes of data
  164.   :Input.    ChangeCnt: last changenumber to check diskchanges
  165.   :Result.   error number or 0 if successful
  166.   :Semantic. Writes whole track to disk
  167. *)
  168.  
  169. PROCEDURE Clear(Unit: DiskUnit): Byte;
  170.  
  171. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  172.   :Result.   error number or 0 if successful
  173.   :Semantic. Marks trackbuffer as invalid --> avoids rewriting it
  174. *)
  175.  
  176. PROCEDURE GetDriveType(Unit: DiskUnit): LONGINT;
  177.  
  178. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  179.   :Result.   1 means 3.5 inch drive connected, 2 means 5.25 inch drive,
  180.   :Result.   other values mean non-standard drives.
  181.   :Note.     WARNING: This command is defined for trackdisk.devices only !
  182.   :Note.     Use GetDeviceInfo() to examine hd-partition's characteristics!
  183. *)
  184.  
  185. PROCEDURE GetNumTracks(Unit: DiskUnit): LONGINT;
  186.  
  187. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  188.   :Result.   total number of tracks the drive has
  189.   :Note.     WARNING: This command is defined for trackdisk.devices only !
  190.   :Note.     Use GetDeviceInfo() to examine HD-partition's characteristics!
  191. *)
  192.  
  193. PROCEDURE InhibitDrive(Unit: DiskUnit;
  194.                        Inhibit: BOOLEAN): BOOLEAN;
  195.  
  196. (*:Input.    Unit: successfully opened DiskUnit (via OpenDiskDevice)
  197.   :Input.    Inhibit: TRUE: FileSystem is stopped from acessing this drive
  198.   :Input.             FALSE: Access is re-enabled
  199.   :Semantic. With this Command, you can stop Dos (FileSystem, DiskValidator)
  200.   :Semantic. from accessing a specific disk drive. The Workbench will
  201.   :Semantic. display "DFx:BUSY", CLI will report "Not a Dos disk" and so on.
  202.   :Semantic. This is useful if you write programms such as "DiskCopy".
  203.   :Result.   TRUE if ok, FALSE if an error occured
  204.   :Note.     More Details about an error can be obtained via Dos.IoErr().
  205. *)
  206.  
  207. END TrackDiskSupport.
  208.